unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, NxCollection, NxScrollControl, NxInspector, DB,
  RzSplit, RzPanel, NxPropertyItemClasses, NxPropertyItems,
  VidGrab, NxCustomGridControl, NxCustomGrid, NxDBGrid, NxPageControl,
  RzBckgnd, RzShellDialogs,StrUtils, RzButton, ImgList, NxDBColumns,
  NxColumns, MemDS, VirtualTable, StdCtrls, NxFieldChooser, NxEdit,
  JvMemoryDataset, DBTables,DateUtils, Menus,
  Mask, RzEdit, ComCtrls, RzLabel, IdBaseComponent,
  IdComponent, IdIRC, IdIOHandler,
  IdIOHandlerSocket, IdIntercept, AdvmWS, AdvMemo, AdvmES, slstbox,
  IdTCPConnection, IdTCPClient, BtnListB, AdvEdit, DBAdvEd, VrControls,
  VrScope, Unit2, JvComponentBase, IdCoder,
  IdCoder3to4, DIZipWriter, JvCipher;

Const
    MAX_R = 10000;

type
  TForm1 = class(TForm)

    RzSplitter1: TRzSplitter;
    RzSizePanel1: TRzSizePanel;
    vg: TVideoGrabber;
    tijdblok: TNextInspector;
    NxTextItem1: TNxTextItem;
    OpenSrt: TNxButtonItem;
    OpenVideo: TNxButtonItem;
    NxPageControl1: TNxPageControl;
    NxTabSheet1: TNxTabSheet;
    Opendialog1: TRzOpenDialog;
    RzGroupBox1: TRzGroupBox;
    il1: TImageList;
    RzToolButton1: TRzToolButton;
    mpause: TRzToolButton;
    mplay: TRzToolButton;
    mstop: TRzToolButton;
    RzToolButton5: TRzToolButton;
    NxTextItem2: TNxTextItem;
    ds1: TDataSource;
    NxLabel2: TNxLabel;
    NextDBGrid1: TNextDBGrid;
    TNxDBTextColumn1: TNxDBTextColumn;
    TNxDBTextColumn2: TNxDBTextColumn;
    TNxDBTextColumn3: TNxDBTextColumn;
    TNxDBTextColumn4: TNxDBTextColumn;
    TNxDBTextColumn5: TNxDBTextColumn;
    TNxDBTextColumn6: TNxDBTextColumn;
    NxCheckBox1: TNxCheckBox;
    mdata: TJvMemoryData;
    TNxDBNumberColumn1: TNxDBProgressColumn;
    pm1: TPopupMenu;
    aantalblok: TNxTextItem;
    totaaltijd: TNxTextItem;
    bloktijd: TNxSpinItem;
    tmr1: TTimer;
    lbltijd: TLabel;
    NxTextItem3: TNxTextItem;
    vcodec: TNxTextItem;
    vframerate: TNxTextItem;
    NxTextItem4: TNxTextItem;
    acodec: TNxTextItem;
    NxTabSheet3: TNxTabSheet;
    NxTabSheet2: TNxTabSheet;
    ircsay: TRzEdit;
    RzToolButton2: TRzToolButton;
    RzGroupBox2: TRzGroupBox;
    ircnaam: TRzEdit;
    RzLabel1: TRzLabel;
    Ircblok: TIdIRC;
    IdConnectionIntercept1: TIdConnectionIntercept;
    IdIOHandlerSocket1: TIdIOHandlerSocket;
    KopieerbloknaarIrc1: TMenuItem;
    ircveld: TAdvMemo;
    AdvEmoticonMemoStyler1: TAdvEmoticonMemoStyler;
    AdvHTMLMemoStyler1: TAdvHTMLMemoStyler;
    NxTextItem5: TNxTextItem;
    dlgSave1: TSaveDialog;
    NxFontNameItem1: TNxFontNameItem;
    NxTabSheet4: TNxTabSheet;
    RzToolButton3: TRzToolButton;
    RzGroupBox3: TRzGroupBox;
    RzToolButton4: TRzToolButton;
    RzToolButton6: TRzToolButton;
    RzToolButton7: TRzToolButton;
    RzToolButton8: TRzToolButton;
    NxTextItem6: TNxTextItem;
    nzbbutton: TNxButtonItem;
    memop: TNxMemoItem;
    cip: TJvCaesarCipher;
    z1: TDIZipWriter;
    procedure OpenSrtButtonClick(Sender: TNxPropertyItem);
    procedure OpenVideoButtonClick(Sender: TNxPropertyItem);
    procedure mpauseClick(Sender: TObject);
    procedure mplayClick(Sender: TObject);
    procedure mstopClick(Sender: TObject);
    procedure tmr1Timer(Sender: TObject);
    procedure vgFrameProgress2(Sender: TObject; FrameInfo: pFrameInfo);
    procedure NextDBGrid1KeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure vgAudioPeak(Sender: TObject; Left_Percent, Left_DB,
      Right_Percent, Right_DB: Double);
    procedure NextDBGrid1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure RzToolButton2Click(Sender: TObject);
    procedure IrcblokConnected(Sender: TObject);
    procedure IrcblokConnect(Sender: TObject);
    procedure ircsayKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure ircdisconnectClick(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure IrcblokMessage(Sender: TObject; AUser: TIdIRCUser;
      AChannel: TIdIRCChannel; Content: String);
    procedure IrcblokChannelUpdate(Sender: TObject;
      AUpdateType: TIdIRCChannelUpdateType; AUser: TIdIRCUser;
      AInfo: Integer);
    procedure NxButtonItem1ButtonClick(Sender: TNxPropertyItem);
    procedure RzToolButton3Click(Sender: TObject);
    procedure RzToolButton7Click(Sender: TObject);
    procedure RzToolButton6Click(Sender: TObject);
    procedure NextDBGrid1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

srtlees = record
      trans: Boolean;
      nr: integer;
      start: string;
      eind: string;
      lijn1org: string;
      lijn2org: string;
      lijn1trans: string;
      lijn2trans: string;
end;

var
  Form1: TForm1;
  trep: TStringList;
  srtrecord: array[1..Max_R] of srtlees;

implementation

{$R *.dfm}

procedure TForm1.OpenSrtButtonClick(Sender: TNxPropertyItem);
var
  readl : textfile;
  num: integer;
  readall : string;
  len: integer;
begin
  num := 1;
  Opendialog1.Filter := 'Srt bestanden (*.Srt)|*.Srt';
  if opendialog1.Execute then begin


  OpenSrt.Value := Opendialog1.FileName;
  mdata.Active := true;
  mdata.Refresh;
  mdata.EmptyTable;
  assignfile(readl,opendialog1.FileName);
  reset(readl);

          while not(eof(readl)) do begin
           readln(readl,readall) ;

              if (readall = inttostr(num)) then begin
               srtrecord[num].trans := False;
               srtrecord[num].nr := strtoint(readall);
               readln(readl,readall);
               srtrecord[num].start := leftstr(readall,12);
               srtrecord[num].eind  := rightstr(readall,12);
               readln(readl,readall);
               srtrecord[num].lijn1org := readall;
               readln(readl,readall);

                  if (readall <> '') then begin
                  srtrecord[num].lijn2org := readall;

                  end;

                  num := num +1;
                end;

           end;

          for len := num-1 downto 1 do begin
           mdata.InsertRecord([srtrecord[len].nr,srtrecord[len].start,srtrecord[len].eind,srtrecord[len].lijn1org,srtrecord[len].lijn2org,srtrecord[Len].lijn1trans,srtrecord[len].lijn2trans,srtrecord[len].trans]);

          end;
         { gmem.SortOnFields('nr',false,true);
         }
          CloseFile(readl);
          aantalblok.Value := IntToStr(NextDBGrid1.RowCount);
          TNxDBNumberColumn1.Max := NextDBGrid1.RowCount;
            {lbllines.Caption := inttostr(totlen) + ' Lijnen';   }

   end;

end;

procedure TForm1.OpenVideoButtonClick(Sender: TNxPropertyItem);
var
  temp : string;
  frame: Double;
begin
     Opendialog1.Filter := 'Media bestanden (*.*)|*.*';
      If opendialog1.Execute then
      begin
        //vg.VideoSource_FileOrURL := jvopendialog1.FileName;
        vg.PlayerFileName := opendialog1.FileName;
        OpenVideo.Value := vg.PlayerFileName;

        vg.OpenPlayer;
        vcodec.Value := vg.PlayerVideoCodec;
        frame := vg.PlayerFrameRate;
        temp := FloatToStr(frame);
        vframerate.Value := temp + ' fps';
        acodec.Value := vg.PlayerAudioCodec;


        //vframerate.Value :=
        //lblvcodec.Caption := vg.VideoCompressorName;
      end;
end;

procedure TForm1.mpauseClick(Sender: TObject);
begin
    vg.PausePlayer;
end;

procedure TForm1.mplayClick(Sender: TObject);
begin
      vg.RunPlayer;
end;

procedure TForm1.mstopClick(Sender: TObject);
begin
      vg.StopPlayer;
      vg.OpenPlayerAtTimePositions(0,0,True,false) ;
end;

procedure TForm1.tmr1Timer(Sender: TObject);
var
  tijds : TDateTime;
  t: Integer;

begin
        if StrToInt(bloktijd.Value) >0 then begin
        t := 60 * StrToInt(bloktijd.Value);
        tijds := t ;
        totaaltijd.Value := TimeToStr(tijds);
        end;
end;

procedure TForm1.vgFrameProgress2(Sender: TObject; FrameInfo: pFrameInfo);
begin
      with FrameInfo^ do begin

          // Formatting de tijd voor video, Gebruik video pointers voor snellere geheugen toevoer.
         lbltijd.Caption := Format ('%.2d:%.2d:%.2d %.2d', [FrameTime_Hour, FrameTime_Min, FrameTime_Sec, FrameTime_Hs]);
      end;
end;

procedure TForm1.NextDBGrid1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);

var
i,sta,sto: int64;
hh,mm,ss,ms,tt,em: int64;
tem,tem2 : string;
row,col: Integer;
begin
      if (Key = VK_UP) or (Key = VK_Down) then begin

      row := NextDBGrid1.SelectedRow;

      hh := 0;
      mm := 0;
      ss := 0;
      ms := 0;
      em := 0;
      //starttime

      hh := strtoint(midstr(NextDBGrid1.CellField[1,row].AsString,1,2)) * 3600;
      mm := strtoint(midstr(nextdbgrid1.CellField[1,row].AsString,4,2))* 60;
      ss := strtoint(midstr(nextdbgrid1.CellField[1,row].AsString,7,2));
      ms := strtoint(midstr(nextdbgrid1.CellField[1,row].AsString,10,3));
        // Hoeft niet aan gezet te worden, deze is compacter.
      //hh := hh * 3600;
      //mm := mm * 60;
      i := hh + mm + ss;
      tem := inttostr(i);
      tem2 := format('%.d%.3d%.4d',[i,ms,em]);
      sta := strtoint64(tem2);
      //Stoptime
      hh := 0;
      mm := 0;
      ss := 0;
      ms := 0;
      em := 0;
      hh := strtoint(midstr(nextdbgrid1.CellField[2,row].AsString,1,2)) * 3600;
      mm := strtoint(midstr(nextdbgrid1.CellField[2,row].AsString,4,2))* 60;
      ss := strtoint(midstr(nextdbgrid1.CellField[2,row].AsString,7,2));
      ms := strtoint(midstr(nextdbgrid1.CellField[2,row].AsString,10,3));
      i := hh + mm + ss;
      tem := inttostr(i);
      tem2 := format('%.d%.3d%.4d',[i,ms,em]);

      sto := strtoint64(tem2);
          if vg.PlayerFileName <> '' then begin
          row := NextDBGrid1.SelectedRow;

          vg.OpenPlayerAtTimePositions(sta,sto,True,false) ;
          vg.TextOverlay_Selector := 1;
          vg.TextOverlay_String := NextDBGrid1.CellField[5,row].AsString;
          vg.TextOverlay_Font.Size := 14;
          vg.TextOverlay_Top := 300;
          //vg.TextOverlay_Left := 0;
          //vg.TextOverlay_Align := tf_center;


          vg.TextOverlay_Enabled := true;
          Vg.TextOverlay_Selector := 2;
          vg.TextOverlay_String := NextDBGrid1.CellField[6,row].AsString;
          vg.TextOverlay_Font.Size := 14;
          vg.TextOverlay_Top := 320;
          vg.TextOverlay_Enabled :=true;
          end;


       end;

       if (Key = VK_F1) then begin
         vg.RunPlayer;

         end;

       if (key = VK_F2) then begin
         row := NextDBGrid1.SelectedRow;


       end;

       if (Key = Vk_Return) then begin
         row := NextDBGrid1.SelectedRow;
          vg.TextOverlay_Selector := 1;
          vg.TextOverlay_String := NextDBGrid1.CellField[5,row].AsString;
          vg.TextOverlay_Font.Size := 14;
          vg.TextOverlay_Top := 300;
          vg.TextOverlay_Enabled := true;

          Vg.TextOverlay_Selector := 2;
          vg.TextOverlay_String := NextDBGrid1.CellField[6,row].AsString;
          vg.TextOverlay_Font.Size := 14;
          vg.TextOverlay_Top := 320;
          vg.TextOverlay_Enabled :=true;
       end;



end;


procedure TForm1.vgAudioPeak(Sender: TObject; Left_Percent, Left_DB,
  Right_Percent, Right_DB: Double);
begin

   //vg.SetVUMeterSetting(LEFT_DB,vu_Handle,vupanel.Handle);

end;

procedure TForm1.NextDBGrid1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);

var
i,sta,sto: int64;
hh,mm,ss,ms,tt,em: int64;
tem,tem2 : string;
row,col: Integer;
timers : TDateTime;

begin
      if (ssCtrl in Shift) and (Key = VK_left)  then begin
          longtimeformat := 'hh:nn:ss,zzz';
          row := NextDBGrid1.SelectedRow;

          tem := NextDBGrid1.CellField[1,row].AsString;

          timers := StrToTime(tem);
          timers := incmillisecond(timers,-100);

          NextDBGrid1.Cells[1,row] := (formatdatetime('hh:nn:ss,zzz',timers));

           hh := 0;
           mm := 0;
           ss := 0;
           ms := 0;
           em := 0;
            //starttime

           hh := strtoint(midstr(NextDBGrid1.CellField[1,row].AsString,1,2)) * 3600;
      mm := strtoint(midstr(nextdbgrid1.CellField[1,row].AsString,4,2))* 60;
      ss := strtoint(midstr(nextdbgrid1.CellField[1,row].AsString,7,2));
      ms := strtoint(midstr(nextdbgrid1.CellField[1,row].AsString,10,3));
        // Hoeft niet aan gezet te worden, deze is Fucking compacter.
        //MOET eigenlijk dit in een functie zetten, maar tijd is schaars.
      //hh := hh * 3600;
      //mm := mm * 60;
      i := hh + mm + ss;
      tem := inttostr(i);
      tem2 := format('%.d%.3d%.4d',[i,ms,em]);
      sta := strtoint64(tem2);
      //Stoptime
      hh := 0;
      mm := 0;
      ss := 0;
      ms := 0;
      em := 0;
      hh := strtoint(midstr(nextdbgrid1.CellField[2,row].AsString,1,2)) * 3600;
      mm := strtoint(midstr(nextdbgrid1.CellField[2,row].AsString,4,2))* 60;
      ss := strtoint(midstr(nextdbgrid1.CellField[2,row].AsString,7,2));
      ms := strtoint(midstr(nextdbgrid1.CellField[2,row].AsString,10,3));
      i := hh + mm + ss;
      tem := inttostr(i);
      tem2 := format('%.d%.3d%.4d',[i,ms,em]);

      sto := strtoint64(tem2);
      vg.OpenPlayerAtTimePositions(sta,sto,True,false) ;
    end;

          if (ssCtrl in Shift) and (Key = VK_right)  then begin
          longtimeformat := 'hh:nn:ss,zzz';
          row := NextDBGrid1.SelectedRow;

          tem := NextDBGrid1.CellField[1,row].AsString;

          timers := StrToTime(tem);
          timers := incmillisecond(timers,100);

          NextDBGrid1.Cells[1,row] := (formatdatetime('hh:nn:ss,zzz',timers));

           hh := 0;
           mm := 0;
           ss := 0;
           ms := 0;
           em := 0;
            //starttime

           hh := strtoint(midstr(NextDBGrid1.CellField[1,row].AsString,1,2)) * 3600;
      mm := strtoint(midstr(nextdbgrid1.CellField[1,row].AsString,4,2))* 60;
      ss := strtoint(midstr(nextdbgrid1.CellField[1,row].AsString,7,2));
      ms := strtoint(midstr(nextdbgrid1.CellField[1,row].AsString,10,3));
        // Hoeft niet aan gezet te worden, deze is compacter.
      //hh := hh * 3600;
      //mm := mm * 60;
      i := hh + mm + ss;
      tem := inttostr(i);
      tem2 := format('%.d%.3d%.4d',[i,ms,em]);
      sta := strtoint64(tem2);
      //Stoptime
      hh := 0;
      mm := 0;
      ss := 0;
      ms := 0;
      em := 0;
      hh := strtoint(midstr(nextdbgrid1.CellField[2,row].AsString,1,2)) * 3600;
      mm := strtoint(midstr(nextdbgrid1.CellField[2,row].AsString,4,2))* 60;
      ss := strtoint(midstr(nextdbgrid1.CellField[2,row].AsString,7,2));
      ms := strtoint(midstr(nextdbgrid1.CellField[2,row].AsString,10,3));
      i := hh + mm + ss;
      tem := inttostr(i);
      tem2 := format('%.d%.3d%.4d',[i,ms,em]);

      sto := strtoint64(tem2);
      vg.OpenPlayerAtTimePositions(sta,sto,True,false) ;
    end;
end;


procedure TForm1.RzToolButton2Click(Sender: TObject);
begin
    if (ircnaam.Text = '') then begin

     ShowMessage('Vul een naam in voor gebruik met IRC');
     Exit;

    end;
 Ircblok.Host := 'irc.bierdopje.com';
 Ircblok.Port := 6667;
 Ircblok.Nick := ircnaam.Text;
 try                   // Try is een belangrijke pointer hier.
   Ircblok.Connect(30);
   Ircblok.Join('#Bierdopje');
    except

    if not Ircblok.Connected then

      begin

        MessageDlg('Probleem met verbinden naar ' + Ircblok.Host, mtError,
         [mbOK], 0);

        Exit;

      end;

      end;


end;

procedure TForm1.IrcblokConnected(Sender: TObject);
begin
   ircveld.Lines.Add('Verbonden met Bierdopje..') ;
   ircveld.Lines.Add('Verbinding maken met Bierdopje...') ;
end;

procedure TForm1.IrcblokConnect(Sender: TObject);
begin

   ircveld.Lines.Add('Verbonden met Bierdopje..') ;
   Ircblok.Join('#Bierdopje');

end;

procedure TForm1.ircsayKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
   // RAW Functie werkt nog niet
   if Key = VK_RETURN then begin
     //Ircblok.Raw(ircsay.Text);
     Ircblok.Say('#bierdopje',ircsay.text);
     ircveld.Lines.Append(ircnaam.Text + ': '+ircsay.Text);
     ircsay.Text := '';


    end;
end;
procedure TForm1.ircdisconnectClick(Sender: TObject);
begin

   Ircblok.DisconnectSocket;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  //KLOTE IRC !!!!!!!! Waarom moet deze nou op hier crashen ??
   if Ircblok.Connected then begin
      Ircblok.DisconnectSocket;
      Ircblok.Destroy;
 end;
end;

procedure TForm1.IrcblokMessage(Sender: TObject; AUser: TIdIRCUser;
  AChannel: TIdIRCChannel; Content: String);
begin
    ircveld.Lines.Append(AUser.Nick + ': ' +Content);


end;

procedure TForm1.IrcblokChannelUpdate(Sender: TObject;
  AUpdateType: TIdIRCChannelUpdateType; AUser: TIdIRCUser; AInfo: Integer);
  var
    i: Integer;
begin

end;

procedure TForm1.NxButtonItem1ButtonClick(Sender: TNxPropertyItem);
var
  len: Integer;
  f: TextFile;
begin

  if dlgSave1.Execute then begin
        //REwrite de save Engine, deze is sneller en lekker compact
        //EDIT : Functie verbouwen om CellField te gebruiken ipv deze loop.
       AssignFile(f,dlgSave1.FileName);
       Rewrite(f);
       mdata.First;
     //NextDBGrid1.SelectFirstRow();
       For len := 0 to NextDBGrid1.RowCount-1 do begin

               Writeln(f, string(mdata.Fields.Fields[0].AsString));
               Writeln(f, string(mdata.Fields.Fields[1].AsString + ' --> ' + mdata.Fields.Fields[2].AsString));
               Writeln(f, string(mdata.Fields.Fields[5].AsString));
               Writeln(f, string(mdata.Fields.Fields[6].AsString));
               Writeln(f, string(''));
//                Writeln(f, string(IntToStr(len)));
//                Writeln(f, string(TNxDBTextColumn1.Field.AsString +' --> ' + TNxDBTextColumn2.Field.AsString));
//                Writeln(f, string(TNxDBTextColumn5.Field.AsString));
//                Writeln(f, string(TNxDBTextColumn6.Field.AsString));
//                Writeln(f, string(''));

          // NextDBGrid1.MoveSelectionDown();
           mdata.Next;
       end;

      CloseFile(f);
      NextDBGrid1.SelectFirstRow();
  end;
end;

procedure TForm1.RzToolButton3Click(Sender: TObject);
var
  readx : TextFile;
  writer : TextFile;
  lees,tem: String;
  i : Integer;


begin
  Opendialog1.Filter := 'Nzb bestanden (*.nzb)|*.nzb';

  if Opendialog1.Execute then begin
     AssignFile(readx,Opendialog1.FileName);


        Reset(readx);

           while not (Eof(readx)) do begin

             Readln(readx, lees);
               cip.Decoded := lees;
                ircveld.Lines.Add(cip.Encoded);




          end;

           CloseFile(readx);

            for i:= 0 to ircveld.Lines.Count -1 do begin



            end;

        end;



end;

procedure TForm1.RzToolButton7Click(Sender: TObject);
var
  len: Integer;
  f: TextFile;
begin
   dlgSave1.Filter := 'Srt bestanden (*.Srt)|*.Srt';
  if dlgSave1.Execute then begin
        //REwrite de save Engine, deze is sneller en lekker compact
        //EDIT : Functie verbouwen om CellField te gebruiken ipv deze loop.
       AssignFile(f,dlgSave1.FileName);
       Rewrite(f);
       mdata.First;
     //NextDBGrid1.SelectFirstRow();
       For len := 0 to NextDBGrid1.RowCount-1 do begin

               Writeln(f, string(mdata.Fields.Fields[0].AsString));
               Writeln(f, string(mdata.Fields.Fields[1].AsString + ' --> ' + mdata.Fields.Fields[2].AsString));
               Writeln(f, string(mdata.Fields.Fields[5].AsString));
               Writeln(f, string(mdata.Fields.Fields[6].AsString));
               Writeln(f, string(''));
//                Writeln(f, string(IntToStr(len)));
//                Writeln(f, string(TNxDBTextColumn1.Field.AsString +' --> ' + TNxDBTextColumn2.Field.AsString));
//                Writeln(f, string(TNxDBTextColumn5.Field.AsString));
//                Writeln(f, string(TNxDBTextColumn6.Field.AsString));
//                Writeln(f, string(''));

          // NextDBGrid1.MoveSelectionDown();
           mdata.Next;
       end;

      CloseFile(f);
      NextDBGrid1.SelectFirstRow();
  end;

end;

procedure TForm1.RzToolButton6Click(Sender: TObject);
var
  len: Integer;
  f: TextFile;
begin
  dlgSave1.Filter := 'SrtV2 bestanden (*.SrtV2)|*.SrtV2';
  if dlgSave1.Execute then begin
        //REwrite de save Engine, deze is sneller en lekker compact
        //EDIT : Functie verbouwen om CellField te gebruiken ipv deze loop.
       AssignFile(f,dlgSave1.FileName);
       Rewrite(f);
       mdata.First;
     //NextDBGrid1.SelectFirstRow();
       For len := 0 to NextDBGrid1.RowCount-1 do begin

               Writeln(f, string(mdata.Fields.Fields[0].AsString));
               Writeln(f, string(mdata.Fields.Fields[1].AsString + ' --> ' + mdata.Fields.Fields[2].AsString));
               Writeln(f, string(mdata.Fields.Fields[3].AsString));
               Writeln(f, string(mdata.Fields.Fields[4].AsString));
               Writeln(f, string(mdata.Fields.Fields[5].AsString));
               Writeln(f, string(mdata.Fields.Fields[6].AsString));
               Writeln(f, string(''));
//                Writeln(f, string(IntToStr(len)));
//                Writeln(f, string(TNxDBTextColumn1.Field.AsString +' --> ' + TNxDBTextColumn2.Field.AsString));
//                Writeln(f, string(TNxDBTextColumn5.Field.AsString));
//                Writeln(f, string(TNxDBTextColumn6.Field.AsString));
//                Writeln(f, string(''));

          // NextDBGrid1.MoveSelectionDown();
           mdata.Next;
       end;

      CloseFile(f);
      NextDBGrid1.SelectFirstRow();
  end;

end;

procedure TForm1.NextDBGrid1Click(Sender: TObject);

var
i,sta,sto: int64;
hh,mm,ss,ms,tt,em: int64;
tem,tem2 : string;
row,col: Integer;
begin
        row := NextDBGrid1.SelectedRow;

      hh := 0;
      mm := 0;
      ss := 0;
      ms := 0;
      em := 0;
      //starttime

      hh := strtoint(midstr(NextDBGrid1.CellField[1,row].AsString,1,2)) * 3600;
      mm := strtoint(midstr(nextdbgrid1.CellField[1,row].AsString,4,2))* 60;
      ss := strtoint(midstr(nextdbgrid1.CellField[1,row].AsString,7,2));
      ms := strtoint(midstr(nextdbgrid1.CellField[1,row].AsString,10,3));
        // Hoeft niet aan gezet te worden, deze is compacter.
      //hh := hh * 3600;
      //mm := mm * 60;
      i := hh + mm + ss;
      tem := inttostr(i);
      tem2 := format('%.d%.3d%.4d',[i,ms,em]);
      sta := strtoint64(tem2);
      //Stoptime
      hh := 0;
      mm := 0;
      ss := 0;
      ms := 0;
      em := 0;
      hh := strtoint(midstr(nextdbgrid1.CellField[2,row].AsString,1,2)) * 3600;
      mm := strtoint(midstr(nextdbgrid1.CellField[2,row].AsString,4,2))* 60;
      ss := strtoint(midstr(nextdbgrid1.CellField[2,row].AsString,7,2));
      ms := strtoint(midstr(nextdbgrid1.CellField[2,row].AsString,10,3));
      i := hh + mm + ss;
      tem := inttostr(i);
      tem2 := format('%.d%.3d%.4d',[i,ms,em]);

      sto := strtoint64(tem2);
          if vg.PlayerFileName <> '' then begin
          row := NextDBGrid1.SelectedRow;

          vg.OpenPlayerAtTimePositions(sta,sto,True,false) ;
          vg.TextOverlay_Selector := 1;
          vg.TextOverlay_String := NextDBGrid1.CellField[5,row].AsString;
          vg.TextOverlay_Font.Size := 14;
          vg.TextOverlay_Top := 300;
          //vg.TextOverlay_Left := 0;
          //vg.TextOverlay_Align := tf_center;


          vg.TextOverlay_Enabled := true;
          Vg.TextOverlay_Selector := 2;
          vg.TextOverlay_String := NextDBGrid1.CellField[6,row].AsString;
          vg.TextOverlay_Font.Size := 14;
          vg.TextOverlay_Top := 320;
          vg.TextOverlay_Enabled :=true;
          end;


       end;

end;

end.

